/* GUI CONVERTED from glcopm.p (converter v1.76) Thu Apr 11 07:18:34 2002 */
/* glcopm.p - GL COMPANY CONTROL FILE MAINTENANCE                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.16 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 1.0      LAST MODIFIED: 06/26/86   BY: JMS                 */
/* REVISION: 4.0                     04/13/88   BY: JMS                 */
/*                                   08/25/89   by: jms  *A391*         */
/*                                   09/06/88   by: jms  *A392*         */
/* REVISION: 5.0      LAST MODIFIED: 03/01/89   by: jms  *B066*         */
/* REVISION: 6.0      LAST MODIFIED: 08/20/90   by: jms  *D034*         */
/* REVISION: 7.0      LAST MODIFIED: 01/13/92   by: jms  *F058*         */
/*                                   05/27/92   by: jms  *F536*         */
/* REVISION: 7.3      LAST MODIFIED: 02/10/93   by: jms  *G703*         */
/* Revision: 7.3      Last Modified: 05/06/94   By: kws  *GJ68*         */
/* Revision: 7.3      Last Modified: 08/30/94   by: srk  *GL33*         */
/* REVISION: 7.3      LAST MODIFIED: 01/23/95   by: str  *F0FB*         */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane    */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 05/05/98   BY: *L018* Russ Witt    */
/* REVISION: 8.6E     LAST MODIFIED: 06/30/98   BY: *J2P4* Samir Bavkar */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan     */
/* REVISION: 9.1      LAST MODIFIED: 06/11/99   BY: *N00D* Chris Green    */
/* REVISION: 9.1      LAST MODIFIED: 08/27/99   BY: *N014* Vijaya Pakala  */
/* REVISION: 9.1      LAST MODIFIED: 06/26/00   BY: *N0DJ* Mudit Mehta    */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0L1* Mark Brown     */
/* REVISION: 9.1      LAST MODIFIED: 09/27/00   BY: *N0VN* Mudit Mehta    */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.16 $    BY: Karel Groos           DATE: 03/26/02  ECO: *N1B3*  */
/* $Revision: eb2 sp3 $    BY: Joy Huang          DATE: 11/10/03  ECO: *HK-S-003*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/**************************************************************************/

/* DISPLAY TITLE */
{mfdtitle.i "C+ "}
{cxcustom.i "GLCOPM.P"}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE glcopm_p_1 "Daily/Continuous Reference Sequence"
/* MaxLen: Comment: */

&SCOPED-DEFINE glcopm_p_2 "Daily/Continuous"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable del-yn       like mfc_logical initial no.
/*HK-S-003    define variable co_daily_seq like mfc_logical
   format {&glcopm_p_2}
   label {&glcopm_p_1}.*/
/*HK-S-003*/   define variable co_daily_seq like mfc_logical
   format "Daily/Month"
   label "Daily/Month Reference Sequence".

/* MOVED THE FOLLOWING LOGIC BELOW */

{glcopmfm.i} /* frame definition */

view frame glcopm-a.

ststatus = stline[3].
status input ststatus.

repeat:

   /* ADD MFC_CTRL FIELD co_daily_seq */
   for first mfc_ctrl where mfc_field = "co_daily_seq"
   exclusive-lock:
   end.
   if not available mfc_ctrl then do:
      create mfc_ctrl.
      assign
         mfc_label   = getTermLabel("DAILY/CONTINUOUS_REFERENCE_SEQUENCE",35)
         mfc_field   = "co_daily_seq"
         mfc_type    = "L"

         mfc_module  = "GL"
         mfc_seq     = 20
         mfc_logical = yes.
   end.
   assign
      co_daily_seq = mfc_logical.

   find first co_ctrl no-error.
   if not available co_ctrl then do:
      /* ADD */
      {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}    /* ADDING NEW RECORD */
      create co_ctrl.
   end.

   else do:
      /* MODIFY */
      {pxmsg.i &MSGNUM=10 &ERRORLEVEL=1}   /* MODIFYING EXISTING RECORD */
   end.

   display co_pl
       co_ret
       co_trns_acct
       co_fx_acct
       co_use_sub
       co_use_cc
       co_enty_bal
       co_allow_mod
       co_cont_page
       co_page_num
           co_daily_seq
       co_audglt
       co_sup_reop
   with frame glcopm-a.

   loopa:
   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      set co_pl
      co_ret
      co_trns_acct
      co_fx_acct
      co_use_sub
      co_use_cc
      co_enty_bal
      co_allow_mod
      co_cont_page
      co_page_num
          co_daily_seq
      co_audglt
      co_sup_reop
      with frame glcopm-a.

      /* VALIDATE ACCOUNTS */
      find first gl_ctrl no-lock.
      if available gl_ctrl then do:
         if gl_verify then do:
            if not can-find(ac_mstr where ac_code = co_pl) then do:
               {pxmsg.i &MSGNUM=3052 &ERRORLEVEL=3} /* INVALID ACCOUNT CODE */

               next-prompt co_pl with frame glcopm-a.
               undo loopa.
            end.
            if not can-find(ac_mstr where ac_code = co_ret) then do:
               {pxmsg.i &MSGNUM=3052 &ERRORLEVEL=3} /* INVALID ACCOUNT CODE */

               next-prompt co_ret with frame glcopm-a.
               undo loopa.
            end.

            if not can-find(ac_mstr where ac_code = co_trns_acct)
               and co_trns_acct <> "" then do:
               {pxmsg.i &MSGNUM=3052 &ERRORLEVEL=3} /* INVALID ACCOUNT CODE */

               next-prompt co_trns_acct with frame glcopm-a.
               undo loopa.
            end.
            if not can-find(ac_mstr where ac_code = co_fx_acct)
               and co_fx_acct <> "" then do:
               {pxmsg.i &MSGNUM=3052 &ERRORLEVEL=3} /* INVALID ACCOUNT CODE */

               next-prompt co_fx_acct with frame glcopm-a.
               undo loopa.
            end.

            /* CHECK IF VALID ACCOUNT IS ACTIVE */
            if can-find(ac_mstr where ac_code = co_pl and
               ac_active = no use-index ac_active) then do:
               {pxmsg.i &MSGNUM=3136 &ERRORLEVEL=3} /* INACTIVE ACCOUNT */
               next-prompt co_pl with frame glcopm-a.
               undo loopa.
            end.
            if can-find(ac_mstr where ac_code = co_ret and
               ac_active = no use-index ac_active) then do:
               {pxmsg.i &MSGNUM=3136 &ERRORLEVEL=3} /* INACTIVE ACCOUNT */
               next-prompt co_ret with frame glcopm-a.
               undo loopa.
            end.

            if can-find(ac_mstr where ac_code = co_trns_acct and
               ac_active = no use-index ac_active) then do:
               {pxmsg.i &MSGNUM=3136 &ERRORLEVEL=3} /* INACTIVE ACCOUNT */
               next-prompt co_trns_acct with frame glcopm-a.
               undo loopa.
            end.
            if can-find(ac_mstr where ac_code = co_fx_acct and
               ac_active = no use-index ac_active) then do:
               {pxmsg.i &MSGNUM=3136 &ERRORLEVEL=3} /* INACTIVE ACCOUNT */
               next-prompt co_fx_acct with frame glcopm-a.
               undo loopa.
            end.

         end.
      end.

      /* CHECK ALLOCATION DETAIL FOR SUBACCT USE */
      /* IF CO_USE_SUB IS CHANGED TO NO          */
      if not co_use_sub then do:
         find first ald_det where ald_code <> ""
            and ald_acc <> ""
            and ald_sub <> "" no-lock no-error.
         if available ald_det then do:
            {pxmsg.i &MSGNUM=3188 &ERRORLEVEL=4}
            /*ALLOCATION CODES EXIST WITH SUBACCT*/
            next-prompt co_use_sub with frame glcopm-a.
            undo loopa, retry.
         end.
      end.

      /* CHECK ALLOCATION DETAIL FOR CC USE */
      /* IF CO_USE_CC IS NO                 */
      if not co_use_cc then do:
         find first ald_det where ald_code <> ""
            and ald_acc <> ""
            and ald_cc <> "" no-lock no-error.
         if available ald_det then do:
            {pxmsg.i &MSGNUM=3189 &ERRORLEVEL=4}
            /*ALLOCATION CODES EXIST WITH CC*/
            next-prompt co_use_cc with frame glcopm-a.
            undo loopa, retry.
         end.
      end.

      {&GLCOPM-P-TAG1}
   end.
/*GUI*/ if global-beam-me-up then undo, leave.


   mfc_logical = co_daily_seq.

   /* ADD BLANK COST CENTER AND SUB-ACCOUNT IF NEEDED */
   find first cc_mstr where cc_ctr = "" no-lock no-error.
   if not available cc_mstr then do:
      create cc_mstr.
      assign
         cc_desc = getTermLabel("BLANK",24)
         cc_ctr = ""
         .

      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "CC_ACCT".
      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "CC_SUB".

   end.
   find first sb_mstr where sb_sub = "" no-lock no-error.
   if not available sb_mstr then do:
      create sb_mstr.
      assign
         sb_desc = getTermLabel("BLANK",24)
         sb_sub = ""
         .

      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "SUB_ACCT".

   end.

   for first pj_mstr where pj_project = "" exclusive-lock:
   end.
   if not available (pj_mstr) then do:
      create pj_mstr.

      assign pj_desc    = getTermLabel("BLANK",24)
         pj_active  = yes
         pj_beg_dt  = today
         pj_findate = today.

      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "PJ_ACCT".

      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "PJ_SUB".

      create cr_mstr.
      assign cr_code       = ""
         cr_mod_date   = today
         cr_mod_userid = global_userid
         cr_code_end   = hi_char
         cr_type       = "PJ_CC".

   end.

end. /* REPEAT */
status input.
